package com.yimi.yinhepda.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yimi.yinhepda.R;
import com.yimi.yinhepda.entity.bean.DeleteEntity;

import java.util.List;

/**
 * @author 000432
 * @date 2017/4/11 0011
 *
 * 建包-撤销adapter
 */

public class DeleteByHandAdapter extends BaseAdapter {

  private Context mContext;
  private List<DeleteEntity> mDeleteEntityList;

  public DeleteByHandAdapter(Context context, List<DeleteEntity> deleteEntityList) {
    this.mContext = context;
    this.mDeleteEntityList = deleteEntityList;
  }

  @Override public View getView(int position, View convertView, ViewGroup viewGroup) {
    ViewHolder viewHolder;
    if (convertView == null) {
      viewHolder = new ViewHolder();
      convertView = LayoutInflater.from(mContext).inflate(R.layout.activity_del_scaned_waybillitem, null);
      viewHolder.mTvWayBillNum =  convertView.findViewById(R.id.cancelwaybill);
      viewHolder.mTvScannedNum =  convertView.findViewById(R.id.scanedwaybillnum);
      viewHolder.mTvDeleteNum = convertView.findViewById(R.id.canceledwaybillnum);
      convertView.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }
    //运单号
    viewHolder.mTvWayBillNum.setText(mDeleteEntityList.get(position).getWayBillNo());
    viewHolder.mTvScannedNum.setText(mDeleteEntityList.get(position).getScannedNum() + "");
    viewHolder.mTvDeleteNum.setText(mDeleteEntityList.get(position).getDeleteNum() + "");

    return convertView;
  }

  public static class ViewHolder {
    /** 运单号 */
    TextView mTvWayBillNum;
    /** 装件（已扫描数量） */
    TextView mTvScannedNum;
    /** 撤销数量 */
    TextView mTvDeleteNum;
  }

  @Override public int getCount() {
    return mDeleteEntityList != null ? mDeleteEntityList.size() : 0;
  }

  @Override public Object getItem(int i) {
    return mDeleteEntityList.get(i);
  }

  @Override public long getItemId(int i) {
    return i;
  }
}
